package com.mz.user.api.impl.controller;



import com.mz.common.domain.SysMenu;
import com.mz.common.domain.SysUser;
import com.mz.common.page.PageList;
import com.mz.common.utils.ResponseResult;
import com.mz.user.api.impl.service.SysUserService;
import com.mz.user.api.query.UserQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 个人信息管理
 * <p>

 */
@RestController
@RequestMapping(value = "usercenter")
public class UserInfoController {

    @Autowired
    private SysUserService sysUserService;

    @Resource
    private BCryptPasswordEncoder passwordEncoder;

    /**
     * 获取个人信息
     */
    @GetMapping(value = "info/{username}")
    public ResponseResult<SysUser> info(@PathVariable String username) {
        SysUser sysUser = sysUserService.get(username);
        return new ResponseResult<SysUser>(ResponseResult.CodeStatus.OK, "获取个人信息", sysUser);
    }


    /**
     * 获取用户对应的菜单
     *
     * @return {@link ResponseResult}
     */
    @GetMapping(value = "findByUserId")
    public ResponseResult findByUserId(@RequestParam("userId") Long userId) throws Exception {
        //返回用户对应的菜单 根据userid查询
        List<SysMenu> sysMenuList = sysUserService.findByUserId(userId);
        return new ResponseResult (ResponseResult.CodeStatus.OK, "获取用户信息", sysMenuList);
    }


}
